#pragma once

#include "cybertron/DefinesCore.hpp"
#include <string>

struct redisContext;
CYBERTRON_BEGIN

class TrafficActorHotArea;
class TrafficActor;
class TrafficActorHotAreaRedisViewer
{
public:
	~TrafficActorHotAreaRedisViewer();
	void Init(const std::string& ip, int port, int dbIndex);
	void RefreshAll(const TrafficActorHotArea*);
	void UpdateHotArea(const TrafficActorHotArea*);
	void UpdateActor(int hotAreaId, const TrafficActor*);
private:
	std::string GetHotAraKey(int hotAreaId);
	std::string GetActorKey(int hotAreaId);
	std::string FormatHotArea(const TrafficActorHotArea*);
	std::string FormatTrafficActor(const TrafficActor*);
	void Write(const std::string& key, const std::string value);
	void Delete(const std::string& key);
	void HashWrite(const std::string& key, const std::string& hashKey, const std::string& value);
	void HashDelete(const std::string& key, const std::string& hashKey);
	redisContext* mRedisContenxt = nullptr;
	bool mRedisReady = false;
};

CYBERTRON_END
